Skip to content

[KeyVault] Add samples for new certificate SANs (IP/URI) and secret secret_encoding/previous_version features#46164

Open
rohitsinghal4u wants to merge 2 commits intomainfrom
samples/keyvault-new-features
Open

[KeyVault] Add samples for new certificate SANs (IP/URI) and secret secret_encoding/previous_version features#46164
rohitsinghal4u wants to merge 2 commits intomainfrom
samples/keyvault-new-features

Conversation

@rohitsinghal4u
Copy link
Copy Markdown
Contributor

Description

This PR adds sample code demonstrating new KeyVault features:

Certificates

  • IP addresses in Subject Alternative Names (SANs) via san_ip_addresses
  • URIs in Subject Alternative Names (SANs) via san_uris

Secrets

  • secret_encoding parameter for format conversion (PFX/PEM)
  • previous_version property on SecretProperties

Files Changed

  • sdk/keyvault/azure-keyvault-certificates/samples/hello_world.py
  • sdk/keyvault/azure-keyvault-secrets/samples/hello_world.py

@rohitsinghal4u rohitsinghal4u requested a review from a team as a code owner April 6, 2026 20:19
Copilot AI review requested due to automatic review settings April 6, 2026 20:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Key Vault hello_world samples to demonstrate recently added features in the azure-keyvault-certificates and azure-keyvault-secrets SDKs.

Changes:

  • Certificates sample: adds san_ip_addresses and san_uris to CertificatePolicy usage.
  • Secrets sample: adds commentary/examples around retrieving certificate-backed secrets in alternate encodings and printing SecretProperties.previous_version.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
sdk/keyvault/azure-keyvault-certificates/samples/hello_world.py Extends certificate policy sample to include IP and URI SAN fields.
sdk/keyvault/azure-keyvault-secrets/samples/hello_world.py Adds sample guidance for certificate-backed secret output encoding and previous_version.

Comment on lines +58 to +60
# For certificate-backed secrets, we can retrieve the secret in a different encoding format using secret_encoding.
# For example, to get a PFX-backed certificate secret in PEM format:
# pem_secret = client.get_secret(secret.name, secret_encoding=ContentType.PEM)
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sample refers to a secret_encoding keyword argument, but SecretClient.get_secret uses out_content_type (see azure.keyvault.secrets._client.SecretClient.get_secret). As written, uncommenting this line would raise TypeError: get_secret() got an unexpected keyword argument 'secret_encoding'. Update the sample text and example call to use out_content_type=ContentType.PEM (or the equivalent MIME type string).

Suggested change
# For certificate-backed secrets, we can retrieve the secret in a different encoding format using secret_encoding.
# For example, to get a PFX-backed certificate secret in PEM format:
# pem_secret = client.get_secret(secret.name, secret_encoding=ContentType.PEM)
# For certificate-backed secrets, we can retrieve the secret in a different encoding format using out_content_type.
# For example, to get a PFX-backed certificate secret in PEM format:
# pem_secret = client.get_secret(secret.name, out_content_type=ContentType.PEM)

Copilot uses AI. Check for mistakes.
Comment on lines +77 to +78
# For secrets created after June 1, 2025, previous_version tracks version history.
# This is useful for certificate-backed secrets.
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says previous_version applies to “secrets created after June 1, 2025”, but the generated model docs state it applies only to certificates created after that date and only for certificate-backed secrets. Please reword this comment to avoid implying all secrets will have version history via previous_version.

Suggested change
# For secrets created after June 1, 2025, previous_version tracks version history.
# This is useful for certificate-backed secrets.
# For certificate-backed secrets, previous_version may be populated to indicate the prior version.
# This applies to certificates created after June 1, 2025, and should not be assumed for all secrets.

Copilot uses AI. Check for mistakes.
…ing), add live out_content_type demo with cert-backed secret, fix utcnow deprecation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

3 participants